Public Class MultiGrupo

    Public Function obtenerGrupo(ByVal pidG As Integer) As Grupo
        Dim peri, hora, asi As String
        Dim idG, idC As Integer
        Dim objGru As Grupo
        Dim dt As DataTable = New accesoBD.TripleCDataSetTableAdapters.selectGrupoTableAdapter().GetData(pidG)
        idG = CInt(dt.Rows.Item(0).Item("idG"))
        peri = CType(dt.Rows.Item(0).Item("periodo"), String)
        hora = CType(dt.Rows.Item(0).Item("horario"), String)
        asi = CType(dt.Rows.Item(0).Item("asistente"), String)
        idC = CInt(dt.Rows.Item(0).Item("idCurso"))
        objGru = New Grupo(peri, hora, asi, idC, idG)
        Return objGru
    End Function

    Public Function obtenerActividad(ByVal pidG As Integer) As Integer
        Dim dt As DataTable = New accesoBD.TripleCDataSetTableAdapters.selectGrupoTableAdapter().GetData(pidG)
        Return CInt(dt.Rows.Item(0).Item("activo"))
    End Function


    Public Function obtenerGruposActivos() As DataTable
        Dim dt As DataTable = New accesoBD.TripleCDataSetTableAdapters.selectGruposActivosTableAdapter().GetData()
        Return dt
    End Function

    Public Function obtenerGrupoInactivo(ByVal pidg As Integer) As DataTable
        Dim dt As DataTable = New accesoBD.TripleCDataSetTableAdapters.reporteITableAdapter().GetData(pidg)
        Return dt
    End Function

    Public Function obtenerGrupoActivo(ByVal pidg As Integer) As DataTable
        Dim dt As DataTable = New accesoBD.TripleCDataSetTableAdapters.reporteATableAdapter().GetData(pidg)
        Return dt
    End Function

    Public Function insertarGrupo(ByVal pperi As String, ByVal phora As String, ByVal pasis As String, ByVal pidC As Integer) As Integer
        Dim objG As New Grupo(pperi, phora, pasis, pidC)
        objG.insertese()
        Dim dt As DataTable = New accesoBD.TripleCDataSetTableAdapters.selectGruposActivosTableAdapter().GetData()
        Dim idG As Integer = CInt(dt.Rows.Item(0).Item("idG"))
        Return idG
    End Function

    Public Sub actualizarGrupo(ByVal pperi As String, ByVal phora As String, ByVal pasis As String, ByVal pidC As Integer, ByVal pidG As Integer)
        Dim objG As New Grupo(pperi, phora, pasis, pidC, pidG)
        objG.actualicese()
    End Sub

    Public Sub eliminarGrupo(ByVal pidC As Integer, ByVal pidG As Integer)
        Try
            Dim da As New accesoBD.TripleCDataSetTableAdapters.QueriesTableAdapter
            da.deleteGrupo(pidG)
        Catch ex As Exception
            Throw New ArgumentException("Existen datos relacionados " & vbNewLine & "          a este grupo")
        End Try
    End Sub

    Public Function obtenerGruposInactivos() As DataTable
        Dim dt As DataTable = New accesoBD.TripleCDataSetTableAdapters.selectGruposInactivosTableAdapter().GetData()
        Return dt
    End Function

End Class
